﻿#include "HelloWorldScene.h"    
#include "AppDelegate.h"
#include "iconv/iconv.h"
#include "CTextField.h"
#include "AppMacros.h"
#include <time.h> 
#define FONTNAME "arial-unicode-26"
#define FONTCOLOR ccBLACK
int __type = 0;

int code_convert(const char *from_charset, const char *to_charset, const char *inbuf, size_t inlen, char *outbuf, size_t outlen)
{

	iconv_t cd;

	const char *temp = inbuf;

	const char **pin = &temp;

	char **pout = &outbuf;

	memset(outbuf,0,outlen);

	cd = iconv_open(to_charset,from_charset);

	if(cd==0) return -1;

	if(iconv(cd,pin,&inlen,pout,&outlen)==-1) return -1;

	iconv_close(cd);

	return 0;

}
/*UTF8转为GB2312*/

std::string u2a(const char *inbuf)

{

	size_t inlen = strlen(inbuf);

	char * outbuf = new char[inlen * 2 + 2];

	std::string strRet;

	if(code_convert("utf-8", "gb2312", inbuf, inlen, outbuf, inlen * 2 + 2) == 0)

	{

		strRet = outbuf;

	}

	delete [] outbuf;

	return strRet;

}
/*GB2312转为UTF8*/
std::string a2u(const char *inbuf)

{

	size_t inlen = strlen(inbuf);

	char * outbuf = new char[inlen * 2 + 2];

	std::string strRet;

	if(code_convert("gb2312", "utf-8", inbuf, inlen, outbuf, inlen * 2 + 2) == 0)

	{

		strRet = outbuf;

	}

	delete [] outbuf;

	return strRet;

}
using namespace cocos2d;

Button_Fire::Button_Fire()
{
	m_pFire = NULL;
	m_pLine = NULL;
	m_other = NULL;
	m_name = NULL;
	m_type = 0;
	m_otherlist = NULL;
	m_otherlist2 = NULL;
	m_isFire = false;
	m_isNameBoardOn =false;
	m_id = 0;
	m_player = NULL;
	m_sun = NULL;
}
Button_Fire::~Button_Fire(){}
void Button_Fire::reset()
{
	m_isFire = false;
	m_pFire->setSelectedState(false);
	m_pFire->onPressStateChangedToNormal();
	m_pLine->onPressStateChangedToNormal();
	if(m_player)
		m_player->onPressStateChangedToPressed();
	//lightNameBoard(true);
	m_sun = NULL;
}
void Button_Fire::push(CCObject* pSender)
{
	if(!hello->m_now->m_nowFire->isbtAvaliable(m_type%100,m_id))
	{
		m_pFire->setSelectedState(!m_isFire);
		return;
	}
	hello->m_now->m_randButton->disable();
	if(!m_isFire)
	{
		lightButtonWithLine(true);
		if(m_type!=1)
			ButtonChainEffects(m_type%100,m_id);
	}
	else
	{
		lightButtonWithLine(false);
		
		if(m_type!=1)
			ButtonChainEffects(m_type%100,m_other->m_id,true);
		else
		{
			lightNameBoard(true);
			m_other->lightNameBoard(true);
		}
	}
	m_pFire->setSelectedState(!m_isFire);
}
void Button_Fire::ButtonChainEffects(int x,int y,bool isCancelling)
{//x为bt前缀1~5,y为bt后缀1~32
	if(x==1)
	{
		int z = (y%2)?y+1:y-1;
		hello->m_now->m_nowFire->lightNameBoard(true,y);
		hello->m_now->m_nowFire->lightNameBoard(false,z);
	}
	else
	{
		if(!isCancelling)
		{
			int offnum=2;//关闭灯盏数
			for(int i=2;i<x;i++)
				offnum *= 2;
			if(y%2==1)
			{
				int offmax=offnum*(y+1);
				hello->m_now->m_nowFire->lightNameBoard(false,offmax-offnum+1,offmax);
			}
			else
			{
				int offmax=offnum*(y-1);
				hello->m_now->m_nowFire->lightNameBoard(false,offmax-offnum+1,offmax);
			}
		}
		if(hello->m_now->m_nowFire->checkLine(x-1,y*2-1))
		{
			ButtonChainEffects(x-1,y*2-1);
		}
		else
		{
			ButtonChainEffects(x-1,y*2);
		}	
	}
}
void Button_Fire::lightNameBoard(bool state)
{
	if(m_type%100!=1)
		return;
	m_isNameBoardOn = state;
	if(state)
		m_player->onPressStateChangedToPressed();
	else
		m_player->onPressStateChangedToNormal();
}
void Button_Fire::lightButtonWithLine(bool state,bool isChain)
{
	if(state)
	{
		
		m_pFire->onPressStateChangedToPressed();
		m_pLine->onPressStateChangedToPressed();
		m_pLine->setWidgetZOrder(m_other->m_pLine->getWidgetZOrder()+1);
		lightNameBoard(true);
		m_isFire = true;
		m_other->lightButtonWithLine(false,true);
	}
	else
	{
		//if(isChain)
			m_pFire->setSelectedState(false);
		//m_pFire->onPressStateChangedToNormal();
		m_pLine->onPressStateChangedToNormal();
		lightNameBoard(false);
		m_isFire = false;
	}
}
cs::CocoWidget* HelloWorld::getWidget(const char* str, cs::CocoWidget* cw)
{
	cs::CocoWidget* ccw = cw->getChildByName(str);
	if (ccw)
	{
		return ccw;
	}
	else
	{
		CCArray* pa = CCArray::createWithArray(cw->getChildren());
		for (unsigned int i=0; i<pa->count(); i++)
		{
			ccw = (cs::CocoWidget*)pa->objectAtIndex(i);
			ccw = getWidget(str, ccw);
			if (ccw)
			{
				return ccw;
			}
		}
	}
}
void HelloWorld::init32()
{
	m_now->m_F32 = new fire;
	
	cs::CocoWidget* pW = COCOUISYSTEM->getCurScene()->getWidgetByName("root32");
	if (pW)
	{
		m_now->m_F32->m_rootNode = pW;
		for (int i=1; i<=32; i++)
		{
			CCString* str = CCString::createWithFormat("1bt_%d", i);
			CCString* str2 = CCString::createWithFormat("1line_%d", i);
			CCString* str3 = CCString::createWithFormat("name%d", i);
			CCString* str4 = CCString::createWithFormat("boardbt_%d", i);
			CCString* str5 = CCString::createWithFormat("board%d", i);
			cs::CocoWidget* pW2 = COCOUISYSTEM->checkWidgetByName(pW, str->getCString());
			cs::CocoWidget* pW3 = COCOUISYSTEM->checkWidgetByName(pW, str2->getCString());
			cs::CocoWidget* pW4 =COCOUISYSTEM->checkWidgetByName(pW, str3->getCString());
			cs::CocoWidget* pW5 =COCOUISYSTEM->checkWidgetByName(pW, str4->getCString());
			cs::CocoWidget* pW6 =COCOUISYSTEM->checkWidgetByName(pW, str5->getCString());
			Button_Fire* pBut = new Button_Fire;
			pBut->m_otherlist = &m_now->m_F32->m_Fire1;
			pBut->m_otherlist2 = &m_now->m_F32->m_Fire2;
			pBut->m_pFire = (cs::CocoCheckBox*)pW2;
			pBut->m_pLine = (cs::CocoButton*)pW3;
			pBut->m_name = (cs::CocoTextField*)pW4;
			pBut->m_player = (cs::CocoButton*)pW5;
			pBut->m_name->disable();
			pBut->m_player->onPressStateChangedToPressed();
			pBut->hello = this;
			cs::CTextField* pTT = (cs::CTextField*)pBut->m_name->getValidNode()->getRenderNode();
			pTT->initWithString("", FONTNAME, pTT->getFontSize());
			pTT->setColor(FONTCOLOR);
			if(pW6)
				pW6->setWidgetZOrder(0);
			pBut->m_id = i;
			pBut->m_type = 1;
			pBut->m_name->setCharacterLength(10);
			pBut->m_name->setPlaceHolder("                 ");
			pBut->m_pFire->addReleaseEvent(pBut, coco_releaseselector(Button_Fire::push));
			if (i % 2 == 0)
			{
				pBut->m_other = m_now->m_F32->m_Fire1.back();
				pBut->m_other->m_other = pBut;
			}
			else
			{
				
			}
			m_now->m_F32->m_Fire1.push_back(pBut);
			str->release();
			str2->release();
			str3->release();
			str4->release();
			str5->release();
		}

		for (int i=1; i<=16; i++)
		{
			CCString* str = CCString::createWithFormat("2bt_%d", i);
			CCString* str2 = CCString::createWithFormat("2line_%d", i);			
			cs::CocoWidget* pW2 = COCOUISYSTEM->checkWidgetByName(pW, str->getCString());
			cs::CocoWidget* pW3 = COCOUISYSTEM->checkWidgetByName(pW, str2->getCString());			
			Button_Fire* pBut = new Button_Fire;
			pBut->m_pFire = (cs::CocoCheckBox*)pW2;
			//pBut->m_pFire->disable();undone
			pBut->m_pLine = (cs::CocoButton*)pW3;		
			pBut->m_type = 2;
			pBut->m_id = i;
			pBut->m_otherlist = &m_now->m_F32->m_Fire2;
			pBut->m_otherlist2 = &m_now->m_F32->m_Fire3;
			pBut->hello = this;
			pBut->m_pFire->addReleaseEvent(pBut, coco_releaseselector(Button_Fire::push));
			if (i % 2 == 0)
			{
				pBut->m_other = m_now->m_F32->m_Fire2.back();
				pBut->m_other->m_other = pBut;
			}
			else
			{

			}
			m_now->m_F32->m_Fire2.push_back(pBut);
			str->release();
			str2->release();
			
		}

		for (int i=1; i<=8; i++)
		{
			CCString* str = CCString::createWithFormat("3bt_%d", i);
			CCString* str2 = CCString::createWithFormat("3line_%d", i);			
			cs::CocoWidget* pW2 = COCOUISYSTEM->checkWidgetByName(pW, str->getCString());
			cs::CocoWidget* pW3 = COCOUISYSTEM->checkWidgetByName(pW, str2->getCString());			
			Button_Fire* pBut = new Button_Fire;
			pBut->m_pFire = (cs::CocoCheckBox*)pW2;
			pBut->m_type = 3;
			pBut->m_id = i;
			pBut->m_pLine = (cs::CocoButton*)pW3;		
			//pBut->m_pFire->disable();undone
			pBut->m_otherlist = &m_now->m_F32->m_Fire3;
			pBut->m_otherlist2 = &m_now->m_F32->m_Fire4;
			pBut->hello = this;
			pBut->m_pFire->addReleaseEvent(pBut, coco_releaseselector(Button_Fire::push));
			if (i % 2 == 0)
			{
				pBut->m_other = m_now->m_F32->m_Fire3.back();
				pBut->m_other->m_other = pBut;
			}
			else
			{

			}
			m_now->m_F32->m_Fire3.push_back(pBut);
			str->release();
			str2->release();
			
		}

		for (int i=1; i<=4; i++)
		{
			CCString* str = CCString::createWithFormat("4bt_%d", i);
			CCString* str2 = CCString::createWithFormat("4line_%d", i);			
			cs::CocoWidget* pW2 = COCOUISYSTEM->checkWidgetByName(pW, str->getCString());
			cs::CocoWidget* pW3 = COCOUISYSTEM->checkWidgetByName(pW, str2->getCString());			
			Button_Fire* pBut = new Button_Fire;
			pBut->m_pFire = (cs::CocoCheckBox*)pW2;
			//pBut->m_pFire->disable();undone
			pBut->m_id = i;
			pBut->m_pLine = (cs::CocoButton*)pW3;	
			pBut->m_otherlist = &m_now->m_F32->m_Fire4;
			pBut->m_otherlist2 = &m_now->m_F32->m_Fire5;
			pBut->m_type = 4;
			pBut->hello = this;
			pBut->m_pFire->addReleaseEvent(pBut, coco_releaseselector(Button_Fire::push));
			if (i % 2 == 0)
			{
				pBut->m_other = m_now->m_F32->m_Fire4.back();
				pBut->m_other->m_other = pBut;
			}
			else
			{

			}
			m_now->m_F32->m_Fire4.push_back(pBut);
			str->release();
			str2->release();
		}

		for (int i=1; i<=2; i++)
		{
			CCString* str = CCString::createWithFormat("5bt_%d", i);
			CCString* str2 = CCString::createWithFormat("5line_%d", i);			
			cs::CocoWidget* pW2 = COCOUISYSTEM->checkWidgetByName(pW, str->getCString());
			cs::CocoWidget* pW3 = COCOUISYSTEM->checkWidgetByName(pW, str2->getCString());			
			Button_Fire* pBut = new Button_Fire;
			pBut->m_pFire = (cs::CocoCheckBox*)pW2;
			//pBut->m_pFire->disable();undone
			pBut->m_pLine = (cs::CocoButton*)pW3;		
			pBut->m_otherlist = &m_now->m_F32->m_Fire5;
			pBut->m_type = 105;
			pBut->m_id = i;
			pBut->hello = this;
			pBut->m_pFire->addReleaseEvent(pBut, coco_releaseselector(Button_Fire::push));
			if (i % 2 == 0)
			{
				pBut->m_other = m_now->m_F32->m_Fire5.back();
				pBut->m_other->m_other = pBut;
			}
			else
			{

			}
			m_now->m_F32->m_Fire5.push_back(pBut);
			str->release();
			str2->release();
		}
	}
}
void HelloWorld::init16()
{
	m_now->m_F16 = new fire;

	cs::CocoWidget* pW = COCOUISYSTEM->getCurScene()->getWidgetByName("root16");
	if (pW)
	{
		m_now->m_F16->m_rootNode = pW;
 		for (int i=1; i<=16; i++)
 		{
 			CCString* str = CCString::createWithFormat("1bt_%d", i);
 			CCString* str2 = CCString::createWithFormat("1line_%d", i);
 			CCString* str3 = CCString::createWithFormat("name%d", i);
 			CCString* str4 = CCString::createWithFormat("boardbt_%d", i);
 			CCString* str5 = CCString::createWithFormat("board%d", i);
 			cs::CocoWidget* pW2 = COCOUISYSTEM->checkWidgetByName(pW, str->getCString());
 			cs::CocoWidget* pW3 = COCOUISYSTEM->checkWidgetByName(pW, str2->getCString());
 			cs::CocoWidget* pW4 =COCOUISYSTEM->checkWidgetByName(pW, str3->getCString());
 			cs::CocoWidget* pW5 =COCOUISYSTEM->checkWidgetByName(pW, str4->getCString());
 			cs::CocoWidget* pW6 =COCOUISYSTEM->checkWidgetByName(pW, str5->getCString());
 			Button_Fire* pBut = new Button_Fire;
 			pBut->m_otherlist = &m_now->m_F16->m_Fire1;
 			pBut->m_otherlist2 = &m_now->m_F16->m_Fire2;
 			pBut->m_pFire = (cs::CocoCheckBox*)pW2;
 			pBut->m_pLine = (cs::CocoButton*)pW3;
 			pBut->m_name = (cs::CocoTextField*)pW4;
 			pBut->m_player = (cs::CocoButton*)pW5;
			pBut->m_name->disable();
			pBut->m_player->onPressStateChangedToPressed();
			cs::CTextField* pTT = (cs::CTextField*)pBut->m_name->getValidNode()->getRenderNode();
			pTT->initWithString("", FONTNAME, pTT->getFontSize());
			pTT->setColor(FONTCOLOR);
 			if(pW6)
 				pW6->setWidgetZOrder(0);
 			pBut->m_id = i;
 			pBut->m_type = 1;
 			pBut->m_name->setCharacterLength(10);
 			pBut->m_name->setPlaceHolder("                 ");
 			pBut->m_pFire->addReleaseEvent(pBut, coco_releaseselector(Button_Fire::push));
			pBut->hello = this;
 			if (i % 2 == 0)
 			{
 				pBut->m_other = m_now->m_F16->m_Fire1.back();
 				pBut->m_other->m_other = pBut;
 			}
 			else
 			{
 
 			}
 			m_now->m_F16->m_Fire1.push_back(pBut);
 			str->release();
 			str2->release();
 			str3->release();
 			str4->release();
 			str5->release();

			//CCLog("%d", i);
 		}
 
 		for (int i=1; i<=8; i++)
 		{
 			CCString* str = CCString::createWithFormat("2bt_%d", i);
 			CCString* str2 = CCString::createWithFormat("2line_%d", i);			
 			cs::CocoWidget* pW2 = COCOUISYSTEM->checkWidgetByName(pW, str->getCString());
 			cs::CocoWidget* pW3 = COCOUISYSTEM->checkWidgetByName(pW, str2->getCString());			
 			Button_Fire* pBut = new Button_Fire;
 			pBut->m_pFire = (cs::CocoCheckBox*)pW2;
 			//pBut->m_pFire->disable();undone
 			pBut->m_pLine = (cs::CocoButton*)pW3;		
 			pBut->m_type = 2;
 			pBut->m_id = i;
 			pBut->m_otherlist = &m_now->m_F16->m_Fire2;
 			pBut->m_otherlist2 = &m_now->m_F16->m_Fire3;
			pBut->hello = this;
 			pBut->m_pFire->addReleaseEvent(pBut, coco_releaseselector(Button_Fire::push));
 			if (i % 2 == 0)
 			{
 				pBut->m_other = m_now->m_F16->m_Fire2.back();
 				pBut->m_other->m_other = pBut;
 			}
 			else
 			{
 
 			}
 			m_now->m_F16->m_Fire2.push_back(pBut);
 			str->release();
 			str2->release();
			//CCLog("%d", i);
 		}
 
 		for (int i=1; i<=4; i++)
 		{
 			CCString* str = CCString::createWithFormat("3bt_%d", i);
 			CCString* str2 = CCString::createWithFormat("3line_%d", i);			
 			cs::CocoWidget* pW2 = COCOUISYSTEM->checkWidgetByName(pW, str->getCString());
 			cs::CocoWidget* pW3 = COCOUISYSTEM->checkWidgetByName(pW, str2->getCString());			
 			Button_Fire* pBut = new Button_Fire;
 			pBut->m_pFire = (cs::CocoCheckBox*)pW2;
 			pBut->m_type = 3;
 			pBut->m_id = i;
 			pBut->m_pLine = (cs::CocoButton*)pW3;		
 			//pBut->m_pFire->disable();undone
 			pBut->m_otherlist = &m_now->m_F16->m_Fire3;
 			pBut->m_otherlist2 = &m_now->m_F16->m_Fire4;
			pBut->hello = this;
 			pBut->m_pFire->addReleaseEvent(pBut, coco_releaseselector(Button_Fire::push));
 			if (i % 2 == 0)
 			{
 				pBut->m_other = m_now->m_F16->m_Fire3.back();
 				pBut->m_other->m_other = pBut;
 			}
 			else
 			{
 
 			}
 			m_now->m_F16->m_Fire3.push_back(pBut);
 			str->release();
 			str2->release();
			//CCLog("%d", i);
 		}
 
 		for (int i=1; i<=2; i++)
 		{
 			CCString* str = CCString::createWithFormat("4bt_%d", i);
 			CCString* str2 = CCString::createWithFormat("4line_%d", i);			
 			cs::CocoWidget* pW2 = COCOUISYSTEM->checkWidgetByName(pW, str->getCString());
 			cs::CocoWidget* pW3 = COCOUISYSTEM->checkWidgetByName(pW, str2->getCString());			
 			Button_Fire* pBut = new Button_Fire;
 			pBut->m_pFire = (cs::CocoCheckBox*)pW2;
 			//pBut->m_pFire->disable();undone
 			pBut->m_id = i;
 			pBut->m_pLine = (cs::CocoButton*)pW3;	
 			pBut->m_otherlist = &m_now->m_F16->m_Fire4;
 			pBut->m_type = 104;
			pBut->hello = this;
 			pBut->m_pFire->addReleaseEvent(pBut, coco_releaseselector(Button_Fire::push));
 			if (i % 2 == 0)
 			{
 				pBut->m_other = m_now->m_F16->m_Fire4.back();
 				pBut->m_other->m_other = pBut;
 			}
 			else
 			{
 
 			}
 			m_now->m_F16->m_Fire4.push_back(pBut);
 			str->release();
 			str2->release();
			//CCLog("%d", i);
 		}
	}
}
void HelloWorld::init8()
{
	m_now->m_F8 = new fire;

	cs::CocoWidget* pW = COCOUISYSTEM->getCurScene()->getWidgetByName("root8");
	if (pW)
	{
		m_now->m_F8->m_rootNode = pW;
		for (int i=1; i<=8; i++)
		{
			CCString* str = CCString::createWithFormat("1bt_%d", i);
			CCString* str2 = CCString::createWithFormat("1line_%d", i);
			CCString* str3 = CCString::createWithFormat("name%d", i);
			CCString* str4 = CCString::createWithFormat("boardbt_%d", i);
			CCString* str5 = CCString::createWithFormat("board%d", i);
			cs::CocoWidget* pW2 = COCOUISYSTEM->checkWidgetByName(pW, str->getCString());
			cs::CocoWidget* pW3 = COCOUISYSTEM->checkWidgetByName(pW, str2->getCString());
			cs::CocoWidget* pW4 =COCOUISYSTEM->checkWidgetByName(pW, str3->getCString());
			cs::CocoWidget* pW5 =COCOUISYSTEM->checkWidgetByName(pW, str4->getCString());
			cs::CocoWidget* pW6 =COCOUISYSTEM->checkWidgetByName(pW, str5->getCString());
			Button_Fire* pBut = new Button_Fire;
			pBut->m_otherlist = &m_now->m_F8->m_Fire1;
			pBut->m_otherlist2 = &m_now->m_F8->m_Fire2;
			pBut->m_pFire = (cs::CocoCheckBox*)pW2;
			pBut->m_pLine = (cs::CocoButton*)pW3;
			pBut->m_name = (cs::CocoTextField*)pW4;
			pBut->m_player = (cs::CocoButton*)pW5;
			pBut->m_name->disable();
			cs::CTextField* pTT = (cs::CTextField*)pBut->m_name->getValidNode()->getRenderNode();
			pTT->initWithString("", FONTNAME, pTT->getFontSize());
			pTT->setColor(FONTCOLOR);
			if(pW6)
				pW6->setWidgetZOrder(0);
			pBut->m_id = i;
			pBut->m_type = 1;
			pBut->hello = this;
			pBut->m_name->setCharacterLength(10);
			pBut->m_name->setPlaceHolder("                 ");
			pBut->m_pFire->addReleaseEvent(pBut, coco_releaseselector(Button_Fire::push));
			if (i % 2 == 0)
			{
				pBut->m_other = m_now->m_F8->m_Fire1.back();
				pBut->m_other->m_other = pBut;
			}
			else
			{

			}
			m_now->m_F8->m_Fire1.push_back(pBut);
			str->release();
			str2->release();
			str3->release();
			str4->release();
			str5->release();
			//CCLog("%d", i);
		}

		for (int i=1; i<=4; i++)
		{
			CCString* str = CCString::createWithFormat("2bt_%d", i);
			CCString* str2 = CCString::createWithFormat("2line_%d", i);			
			cs::CocoWidget* pW2 = COCOUISYSTEM->checkWidgetByName(pW, str->getCString());
			cs::CocoWidget* pW3 = COCOUISYSTEM->checkWidgetByName(pW, str2->getCString());			
			Button_Fire* pBut = new Button_Fire;
			pBut->m_pFire = (cs::CocoCheckBox*)pW2;
			//pBut->m_pFire->disable();undone
			pBut->m_pLine = (cs::CocoButton*)pW3;		
			pBut->m_type = 2;
			pBut->m_id = i;
			pBut->hello = this;
			pBut->m_otherlist = &m_now->m_F8->m_Fire2;
			pBut->m_otherlist2 = &m_now->m_F8->m_Fire3;
			pBut->m_pFire->addReleaseEvent(pBut, coco_releaseselector(Button_Fire::push));
			if (i % 2 == 0)
			{
				pBut->m_other = m_now->m_F8->m_Fire2.back();
				pBut->m_other->m_other = pBut;
			}
			else
			{

			}
			m_now->m_F8->m_Fire2.push_back(pBut);
			str->release();
			str2->release();

		}

		for (int i=1; i<=2; i++)
		{
			CCString* str = CCString::createWithFormat("3bt_%d", i);
			CCString* str2 = CCString::createWithFormat("3line_%d", i);			
			cs::CocoWidget* pW2 = COCOUISYSTEM->checkWidgetByName(pW, str->getCString());
			cs::CocoWidget* pW3 = COCOUISYSTEM->checkWidgetByName(pW, str2->getCString());			
			Button_Fire* pBut = new Button_Fire;
			pBut->m_pFire = (cs::CocoCheckBox*)pW2;
			pBut->m_type = 103;
			pBut->m_id = i;
			pBut->hello = this;
			pBut->m_pLine = (cs::CocoButton*)pW3;		
			//pBut->m_pFire->disable();undone
			pBut->m_otherlist = &m_now->m_F8->m_Fire3;
			pBut->m_pFire->addReleaseEvent(pBut, coco_releaseselector(Button_Fire::push));
			if (i % 2 == 0)
			{
				pBut->m_other = m_now->m_F8->m_Fire3.back();
				pBut->m_other->m_other = pBut;
			}
			else
			{

			}
			m_now->m_F8->m_Fire3.push_back(pBut);
			str->release();
			str2->release();
		}
 	}
}
void HelloWorld::init4()
{
	m_now->m_F4 = new fire;

	cs::CocoWidget* pW = COCOUISYSTEM->getCurScene()->getWidgetByName("root4");
	if (pW)
	{
		m_now->m_F4->m_rootNode = pW;
 		for (int i=1; i<=4; i++)
 		{
 			CCString* str = CCString::createWithFormat("1bt_%d", i);
 			CCString* str2 = CCString::createWithFormat("1line_%d", i);
 			CCString* str3 = CCString::createWithFormat("name%d", i);
 			CCString* str4 = CCString::createWithFormat("boardbt_%d", i);
 			CCString* str5 = CCString::createWithFormat("board%d", i);
 			cs::CocoWidget* pW2 = COCOUISYSTEM->checkWidgetByName(pW, str->getCString());
 			cs::CocoWidget* pW3 = COCOUISYSTEM->checkWidgetByName(pW, str2->getCString());
 			cs::CocoWidget* pW4 =COCOUISYSTEM->checkWidgetByName(pW, str3->getCString());
 			cs::CocoWidget* pW5 =COCOUISYSTEM->checkWidgetByName(pW, str4->getCString());
 			cs::CocoWidget* pW6 =COCOUISYSTEM->checkWidgetByName(pW, str5->getCString());
 			Button_Fire* pBut = new Button_Fire;
 			pBut->m_otherlist = &m_now->m_F4->m_Fire1;
 			pBut->m_otherlist2 = &m_now->m_F4->m_Fire2;
 			pBut->m_pFire = (cs::CocoCheckBox*)pW2;
 			pBut->m_pLine = (cs::CocoButton*)pW3;
 			pBut->m_name = (cs::CocoTextField*)pW4;
 			pBut->m_player = (cs::CocoButton*)pW5;
			pBut->m_name->disable();
			cs::CTextField* pTT = (cs::CTextField*)pBut->m_name->getValidNode()->getRenderNode();
			pTT->initWithString("", FONTNAME, pBut->m_name->getValidNode()->getFontSize());
			pTT->setColor(FONTCOLOR);
			pBut->hello = this;
 			if(pW6)
 				pW6->setWidgetZOrder(0);
 			pBut->m_id = i;
 			pBut->m_type = 1;
 			pBut->m_name->setCharacterLength(10);
 			pBut->m_name->setPlaceHolder("                 ");
 			pBut->m_pFire->addReleaseEvent(pBut, coco_releaseselector(Button_Fire::push));
 			if (i % 2 == 0)
 			{
 				pBut->m_other = m_now->m_F4->m_Fire1.back();
 				pBut->m_other->m_other = pBut;
 			}
 			else
 			{
 
 			}
 			m_now->m_F4->m_Fire1.push_back(pBut);
 			str->release();
 			str2->release();
 			str3->release();
 			str4->release();
 			str5->release();
			//CCLog("%d", i);
 		}
 
 		for (int i=1; i<=2; i++)
 		{
 			CCString* str = CCString::createWithFormat("2bt_%d", i);
 			CCString* str2 = CCString::createWithFormat("2line_%d", i);			
 			cs::CocoWidget* pW2 = COCOUISYSTEM->checkWidgetByName(pW, str->getCString());
 			cs::CocoWidget* pW3 = COCOUISYSTEM->checkWidgetByName(pW, str2->getCString());			
 			Button_Fire* pBut = new Button_Fire;
 			pBut->m_pFire = (cs::CocoCheckBox*)pW2;
 			//pBut->m_pFire->disable();undone
 			pBut->m_pLine = (cs::CocoButton*)pW3;		
 			pBut->m_type = 102;
 			pBut->m_id = i;
				pBut->hello = this;
 			pBut->m_otherlist = &m_now->m_F4->m_Fire2;
 			pBut->m_pFire->addReleaseEvent(pBut, coco_releaseselector(Button_Fire::push));
 			if (i % 2 == 0)
 			{
 				pBut->m_other = m_now->m_F4->m_Fire2.back();
 				pBut->m_other->m_other = pBut;
 			}
 			else
 			{
 
 			}
 			m_now->m_F4->m_Fire2.push_back(pBut);
 			str->release();
 			str2->release();
 
 		}
	}
}
CCScene* HelloWorld::scene()
{
	CCScene * scene = NULL;
	do 
	{
		// 'scene' is an autorelease object
		scene = CCScene::create();
		CC_BREAK_IF(! scene);

		// 'layer' is an autorelease object
		HelloWorld *layer1 = HelloWorld::create();
		layer1->setTag(95);
		CC_BREAK_IF(! layer1);

		// add layer as a child to scene
		scene->addChild(layer1);
// 		scene->addChild(layer2);
// 		scene->addChild(layer3);
// 		scene->addChild(layer4);
	
	} while (0);

	// return the scene
	return scene;
}
void HelloWorld::init_()
{
	m_now->m_checkBox.clear();
	cs::CocoWidget* pw = COCOUISYSTEM->getCurScene()->getWidgetByName("layerbuttons");
	for (size_t i=1; i<=5; i++)
	{
		CCString* str = CCString::createWithFormat("layerbt_%d", i);
		cs::CocoWidget* pW2 = COCOUISYSTEM->checkWidgetByName(pw, str->getCString());
		pW2->setWidgetTag(i);
		m_now->m_checkBox.push_back((cs::CocoCheckBox*)pW2);
		((cs::CocoCheckBox*)pW2)->addPushDownEvent(this, coco_pushselector(HelloWorld::page));
		str->release();
	}
	m_now->m_randBar = (cs::CocoLoadingBar*)COCOUISYSTEM->getWidgetByName("progressbar");
	m_now->m_randBar->setVisible(false);
	sortManager();
	pw = COCOUISYSTEM->getCurScene()->getWidgetByName("bottombuttons");
	m_now->m_randButton = COCOUISYSTEM->checkWidgetByName(pw, "shuffle");
	((cs::CocoCheckBox*)m_now->m_randButton)->addPushDownEvent(this, coco_pushselector(HelloWorld::menuCloseCallback2));
	cs::CocoWidget* pW2 = COCOUISYSTEM->checkWidgetByName(pw, "reset");
	((cs::CocoCheckBox*)pW2)->addPushDownEvent(this, coco_pushselector(HelloWorld::menuCloseCallback));
	m_scoll->setVisible(true);
	STRINGVECTOR strV = m_namelist->getStringV(m_now->m_id);
	STRINGVECTOR::iterator rit = strV.begin();
	for (size_t i=0; i<m_now->m_nowFire->m_Fire1.size(); i++)
	{
		if (rit == strV.end())
		{
			if (i<m_now->m_nowFire->m_Fire1.size())
			{
				showLable();
			}
			break;
		}
		else
		{
			if ((*rit).size() >= 30)
			{
				std::string strTemp = "";
				for (size_t j=0; j<30; j++)
				{
					strTemp += (*rit)[j];
				}
				m_now->m_nowFire->m_Fire1[i]->m_name->setText(strTemp.c_str());
			}
			else
			{
				m_now->m_nowFire->m_Fire1[i]->m_name->setText((*rit).c_str());		
			}
			rit = strV.erase(rit);
		}
	}
	if (!strV.empty())
	{
		showLable();
	}
}
void HelloWorld::sortManagerBalnk()
{
	for (size_t i=0; i<m_check.size(); i++)
	{
		if (m_now->m_id-1 == i)
		{
			showBT(m_check[i]);
		} 
		else
		{
			for (size_t j=0; j< m_pageList.size(); j++)
			{
				if (m_pageList[j]->m_id == (i+1))
				{
					hideBT(m_check[i], m_pageList[j]->m_nowFire, true);
					break;
				}
			}				
		}
	}
}
void HelloWorld::loading(CCObject* pSender)
{
	cs::CocoWidget* pw = (cs::CocoWidget*)pSender;
	int _id = pw->getWidgetTag();
	
	for (size_t i=0; i<m_pageList.size(); i++)
	{
		if (_id == m_pageList[i]->m_id)
		{
			m_now = m_pageList[i];
			break;
		}
	}
	
	if (!m_now->m_nowFire)
	{
		sortManagerBalnk();
		
		setCheckVisble(true);
	}	
	else
	{
		showInit(_id);
		m_loading->setVisible(false);
		m_loading->removeFromParentAndCleanup(false);
	}	
}
void HelloWorld::initLoading()
{
	if (m_loading && !m_loading->getVisible())
	{
		m_loading->setVisible(true);
		COCOUISYSTEM->resetSystem(this);
		COCOUISYSTEM->getCurScene()->addWidget(m_loading);
		sortManagerBalnk();
		setCheckVisble(true);
	}
	else if (m_loading && m_loading->getVisible())
	{
		sortManagerBalnk();
		setCheckVisble(true);
	}
	else
	{
		m_loading = COCOUISYSTEM->createWidgetFromFile_json("blank.json");
		COCOUISYSTEM->resetSystem(this);
		COCOUISYSTEM->getCurScene()->addWidget(m_loading);
		COCOUISYSTEM->getCurScene()->getWidgetByName("root4")->setColor(255, 255, 255);
		cs::CocoWidget* pw = COCOUISYSTEM->getCurScene()->getWidgetByName("layerbuttons");
		for (size_t i=1; i<=5; i++)
		{
			CCString* str = CCString::createWithFormat("layerbt_%d", i);
			cs::CocoWidget* pW2 = COCOUISYSTEM->checkWidgetByName(pw, str->getCString());
			pW2->setWidgetTag(i);
			((cs::CocoCheckBox*)pW2)->addPushDownEvent(this, coco_pushselector(HelloWorld::loading));
			str->release();
			m_check.push_back(pW2);
		}

		pw = COCOUISYSTEM->getCurScene()->getWidgetByName("numButtons");
		for (size_t i=1; i<=4; i++)
		{
			CCString* str = CCString::createWithFormat("numButtons_%d", i);
			cs::CocoWidget* pW2 = COCOUISYSTEM->checkWidgetByName(pw, str->getCString());
			pW2->setWidgetTag(i);
			str->release();
			m_checkMember.push_back(pW2);
		}

		((cs::CocoButton*)m_checkMember[0])->addReleaseEvent(this, coco_pushselector(HelloWorld::check4));
		((cs::CocoButton*)m_checkMember[1])->addReleaseEvent(this, coco_pushselector(HelloWorld::check8));
		((cs::CocoButton*)m_checkMember[2])->addReleaseEvent(this, coco_pushselector(HelloWorld::check16));
		((cs::CocoButton*)m_checkMember[3])->addReleaseEvent(this, coco_pushselector(HelloWorld::check32));

		setCheckVisble(false);
	}		
}
void HelloWorld::check4(CCObject* pSender)
{
	m_loading->setVisible(false);
	m_loading->removeFromParentAndCleanup(false);
	m_now->m_scene = COCOUISYSTEM->createWidgetFromFile_json("game4.json");
	COCOUISYSTEM->resetSystem(this);
	COCOUISYSTEM->getCurScene()->addWidget(m_now->m_scene);
	COCOUISYSTEM->getCurScene()->getWidgetByName("root4")->setColor(255, 255, 255);
	init4();
	m_now->m_nowFire = m_now->m_F4;
	init_();
	
}
void HelloWorld::check8(CCObject* pSender)
{
	m_loading->setVisible(false);
	m_loading->removeFromParentAndCleanup(false);
	m_now->m_scene = COCOUISYSTEM->createWidgetFromFile_json("game8.json");
	COCOUISYSTEM->resetSystem(this);
	COCOUISYSTEM->getCurScene()->addWidget(m_now->m_scene);
	COCOUISYSTEM->getCurScene()->getWidgetByName("root8")->setColor(255, 255, 255);
	init8();
	m_now->m_nowFire = m_now->m_F8;
	init_();	
}
void HelloWorld::check16(CCObject* pSender)
{
	m_loading->setVisible(false);
	m_loading->removeFromParentAndCleanup(false);
	m_now->m_scene = COCOUISYSTEM->createWidgetFromFile_json("game16.json");
	COCOUISYSTEM->resetSystem(this);
	COCOUISYSTEM->getCurScene()->addWidget(m_now->m_scene);
	COCOUISYSTEM->getCurScene()->getWidgetByName("root16")->setColor(255, 255, 255);
	init16();
	m_now->m_nowFire = m_now->m_F16;
	init_();	
}
void HelloWorld::check32(CCObject* pSender)
{
	m_loading->setVisible(false);
	m_loading->removeFromParentAndCleanup(false);
	m_now->m_scene = COCOUISYSTEM->createWidgetFromFile_json("game32.json");
	COCOUISYSTEM->resetSystem(this);
	COCOUISYSTEM->getCurScene()->addWidget(m_now->m_scene);
	COCOUISYSTEM->getCurScene()->getWidgetByName("root32")->setColor(255, 255, 255);
	init32();
	m_now->m_nowFire = m_now->m_F32;
	init_();
}
void HelloWorld::update(float deita)
{
	int a = 1;
}
void HelloWorld::page(CCObject* pSender)
{
	cs::CocoWidget* pw = (cs::CocoWidget*)pSender;
	int _id = pw->getWidgetTag();
	if (_id == m_now->m_id)
	{
		showBT(pw);
	} 
	else
	{
		//showBT(pw);
		m_now->m_scene->removeFromParentAndCleanup(false);
		showInit(_id);
	}
	CCLog("%d", _id);
}
void HelloWorld::showInit(int _id)
{
	for (size_t i=0; i<m_pageList.size(); i++)
	{
		if (_id == m_pageList[i]->m_id)
		{
			m_now = m_pageList[i];
			break;
		}
	}
	sortManager();
	if (m_now->m_scene)
	{		
		COCOUISYSTEM->getCurScene()->addWidget(m_now->m_scene);
		m_scoll->setVisible(true);
	}
	else
	{
		m_scoll->setVisible(false);
		initLoading();
	}
}
void HelloWorld::sortManager()
{
	if (!m_now->m_checkBox.empty())
	{
		for (size_t i=0; i<m_now->m_checkBox.size(); i++)
		{
			if (m_now->m_id-1 == i)
			{
				showBT(m_now->m_checkBox[i]);
			} 
			else
			{
				for (size_t j=0; j< m_pageList.size(); j++)
				{
					if (m_pageList[j]->m_id == (i+1))
					{
						hideBT(m_now->m_checkBox[i], m_pageList[j]->m_nowFire);
						break;
					}
				}				
			}
		}
	}
}
void HelloWorld::showLable()
{
	m_lable->setVisible(true);
	CCSequence* seq = CCSequence::create(
		CCFadeOut::create(0.5f),
		CCFadeIn::create(0.5f),
		CCFadeOut::create(0.5f),
		CCFadeIn::create(0.5f),
		CCFadeOut::create(0.5f),
		CCFadeIn::create(0.5f),
		CCFadeOut::create(0.5f),NULL);
	m_lable->runAction(seq);
}
void HelloWorld::keyBackClicked()
{
	
}
long HelloWorld::currentTimeNow()  
{ 
	struct cc_timeval now; 
	CCTime::gettimeofdayCocos2d(&now, NULL); 
	return (now.tv_sec * 10000 + now.tv_usec / 10000); 
} 
bool HelloWorld::init()
{
	bool bRet = true;
	do 
	{
		CC_BREAK_IF(! CCLayer::init());
		CCFileUtils* pfile = CCFileUtils::sharedFileUtils();
		pfile->addSearchPath("../../Resources");
		pfile->addSearchPath("../../Resources/Image");
		pfile->addSearchPath("../../Resources/Fonts");
		pfile->addSearchPath("../../Groups");
		pfile->addSearchPath("../Resources");
		pfile->addSearchPath("../Resources/Image");
		pfile->addSearchPath("../Resources/Fonts");
		pfile->addSearchPath("../Groups");
		pfile->addSearchPath("../");

		//setKeypadEnabled(true);

		CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
		CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();

		CCLabelTTF* pLabel = CCLabelTTF::create(a2u("人数不匹配！").c_str(), "微软雅黑", TITLE_FONT_SIZE / 2);
		m_lable = pLabel;
		pLabel->setColor(ccc3(237, 15, 105));
		//// position the label on the center of the screen
		pLabel->setPosition(ccp(origin.x + visibleSize.width/2,
			pLabel->getContentSize().height + 40));
		pLabel->setVisible(false);

		//// add the label as a child to this layer
		this->addChild(pLabel, 1);

		pLabel = CCLabelTTF::create(a2u("Powered by COCOS2D-X").c_str(), "arial-unicode-26", TITLE_FONT_SIZE / 3 -4);
		pLabel->setColor(ccBLACK);
		//// position the label on the center of the screen
		pLabel->setPosition(ccp(125, 8));
		this->addChild(pLabel, 1);
		pLabel = CCLabelTTF::create(a2u("Authored by 一念·之间 && 卿晓铭").c_str(), "arial-unicode-26", TITLE_FONT_SIZE / 3 - 4);
		pLabel->setColor(ccBLACK);
	
		//// position the label on the center of the screen
		pLabel->setPosition(ccp(866, 8));
		this->addChild(pLabel, 1);

		CCMenuItemImage *pCloseItem = NULL;		 
		CCMenu* pMenu = NULL; 

		pCloseItem = CCMenuItemImage::create(
			"scrshot.png",
			"scrshot.png",
			this,
			menu_selector(HelloWorld::KeyDown));

		pCloseItem->setPosition(visibleSize.width/2, pCloseItem->getContentSize().height/2 + 20);
		pMenu = CCMenu::create(pCloseItem, NULL);
		pMenu->setPosition(CCPointZero);
		this->addChild(pMenu, 1000);
		m_scoll = pMenu;
		m_scoll->setVisible(false);

		initLoading();
		load();
		//CCTimer::timerWithTarget(this,schedule_selector( HelloWorld::testTimerCB), 0.1f);
		this->schedule(schedule_selector( HelloWorld::testTimerCB), 0.1f); 
		
	}while(0);
	return bRet;
}
void HelloWorld::load()
{
	
	CCString* strTemp = CCString::createWithContentsOfFile("1.txt");
	if (strTemp)
	{
		std::string str = strTemp->getCString();
		namePool::createStringVector(str, m_namelist->name1);
	}
	else
	{
		cocos2d::CCMessageBox("请在groups目录下建立   1.txt", " warning!!");
		CCDirector::sharedDirector()->end();
	}
	strTemp = CCString::createWithContentsOfFile("2.txt");
	if (strTemp)
	{
		std::string str = strTemp->getCString();
		namePool::createStringVector(str, m_namelist->name2);
	}
	else
	{
		cocos2d::CCMessageBox("请在groups目录下建立   2.txt", " warning!!");
		CCDirector::sharedDirector()->end();
	}
	strTemp = CCString::createWithContentsOfFile("3.txt");	
	if (strTemp)
	{
		std::string str = strTemp->getCString();
		namePool::createStringVector(str, m_namelist->name3);
	}
	else
	{
		cocos2d::CCMessageBox("请在groups目录下建立   3.txt", " warning!!");
		CCDirector::sharedDirector()->end();
	}
	strTemp = CCString::createWithContentsOfFile("4.txt");
	if (strTemp)
	{
		std::string str = strTemp->getCString();
		namePool::createStringVector(str, m_namelist->name4);
	}
	else
	{
		cocos2d::CCMessageBox("请在groups目录下建立   4.txt", " warning!!");
		CCDirector::sharedDirector()->end();
	}
	strTemp = CCString::createWithContentsOfFile("5.txt");
	if (strTemp)
	{
		std::string str = strTemp->getCString();
		namePool::createStringVector(str, m_namelist->name5);
	}
	else
	{
		cocos2d::CCMessageBox("请在groups目录下建立   5.txt", " warning!!");
		CCDirector::sharedDirector()->end();
	}
}
#define ISVISBLE(fff, ttt) if(fff && fff->m_rootNode && fff->m_rootNode->getVisible()){ fff->reset(); ttt = true;} else {ttt = false;}
#define ISVISBLER(fff, ttt) if(fff && fff->m_rootNode && fff->m_rootNode->getVisible()){ fff->random(); ttt = true; } else {ttt = false;}
void HelloWorld::testTimerCB(float fetimes)
{
	if (m_isLoading)
	{
		m_now->m_savetimes+=fetimes*40;
		m_now->m_randBar->setPercent(m_now->m_savetimes);
		m_now->m_nowFire->random();
		if (m_now->m_savetimes >= 100)
		{
			m_now->m_savetimes = 0.f;
			m_now->m_randBar->stopAllActions();
			m_isLoading = false;
			CCFadeOut* fo = CCFadeOut::create(0.5f);
			m_now->m_randBar->runAction(fo);
			CCDirector::sharedDirector()->getTouchDispatcher()->setDispatchEvents(true);
		}
	}	
}
void HelloWorld::menuCloseCallback(CCObject* pSender)
{
	// "close" menu item clicked
	//CCDirector::sharedDirector()->getTouchDispatcher()->setDispatchEvents(false);
	bool isVis = false;
	ISVISBLE(m_now->m_F32, isVis);
	ISVISBLE(m_now->m_F16, isVis);
	ISVISBLE(m_now->m_F8, isVis);
	ISVISBLE(m_now->m_F4, isVis);
	m_now->m_randButton->active();
	
}
void HelloWorld::menuCloseCallback2(CCObject* pSender)
{
	// "close" menu item clicked
	if (m_isLoading)
	{
		return;
	}
	bool isVis;
	ISVISBLER(m_now->m_F32, isVis);
	ISVISBLER(m_now->m_F16, isVis);
	ISVISBLER(m_now->m_F8, isVis);
	ISVISBLER(m_now->m_F4, isVis);
	//m_now->m_savetimes+=10.f;
	m_now->m_randBar->setPercent(0);
	m_now->m_randBar->stopAllActions();
	m_now->m_randBar->setVisible(true);
	CCFadeIn* fo = CCFadeIn::create(0.2f);
	m_now->m_randBar->runAction(fo);
	m_isLoading = true;
	CCDirector::sharedDirector()->getTouchDispatcher()->setDispatchEvents(false);
	//CCLog("123123");
}
void HelloWorld::KeyDown(CCObject* pSender)
{
	//CCLog("123123");
	CCSize winsize = CCDirector::sharedDirector()->getWinSize();//c++截图
	CCRenderTexture* jp =CCRenderTexture::create(winsize.width, winsize.height);
	jp->begin();
	CCDirector::sharedDirector()->getRunningScene()->visit();
	jp->end();
	//CCLog("1231234");
	CCString strTemp;
	strTemp.initWithFormat("../../ScreenShots/Prtsc%d.jpg", currentTimeNow());

	//jp->saveToFile(strTemp.getCString(), cocos2d::tCCImageFormat::kCCImageFormatPNG);
	CCImage* jpp = jp->newCCImage(true);
	jpp->saveToFile(strTemp.getCString());
	strTemp.initWithFormat("../ScreenShots/Prtsc%d.jpg", currentTimeNow());
	jpp->saveToFile(strTemp.getCString());
	jp->release();
	jpp->release();
}
HelloWorld::HelloWorld()
{
	for (size_t i=0; i<5; i++)
	{
		manger* ma = new manger;
		ma->m_id = i+1;
		m_pageList.push_back(ma);
	}
	m_now = m_pageList.front();
	m_loading = NULL;
	m_isLoading = false;
	m_namelist = new namePool;
}
HelloWorld::~HelloWorld()
{
	for (size_t i=0; i<m_pageList.size(); i++)
	{
		CC_SAFE_DELETE(m_pageList[i]);
	}
	CC_SAFE_DELETE(m_namelist);
}
void HelloWorld::namePool::createStringVector(std::string& strTemp, STRINGVECTOR& strV)
{
	strV.clear();
	size_t i=0;
	std::string strTemp2 = "";
	while(1)
	{
		char a = strTemp[i++];
		if (a == 10 || a == -1)
		{
			std::string::reverse_iterator it = strTemp2.rbegin();
			int jj = strTemp2.size();
			for (; it!=strTemp2.rend(); it++)
			{
				jj--;
				a = *it;
				if (a == 10 || a == 13 || a == 32)
				{
					strTemp2.erase(jj);
					if (it == strTemp2.rend())
					{
						break;
					}
				}
				else
				{
					break;
				}
			}
			if (!strTemp2.empty())
			{
				strV.push_back(a2u(strTemp2.c_str()));					
			}					
			strTemp2 = "";
		}
		else
		{
			strTemp2 += a;
		}
		if (i >= strTemp.size())
		{
			break;
		}
	}
	if (!strTemp2.empty())
	{
		std::string::reverse_iterator it = strTemp2.rbegin();
		int jj = strTemp2.size();
		for (; it!=strTemp2.rend(); it++)
		{
			jj--;
			char a = *it;
			if (a == 10 || a == 13 || a == 32)
			{
				strTemp2.erase(jj);
				if (it == strTemp2.rend())
				{
					break;
				}
			}
			else
			{
				break;
			}
		}
		if (!strTemp2.empty())
		{
			strV.push_back(a2u(strTemp2.c_str()));					
		}					
		strTemp2 = "";
	}
}
std::string HelloWorld::geta2u(const char* str)
{
	return a2u(str);
}
